#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/9/20 16:32
# @Author  : 王凯
# @File    : app_crawler.py
# @Project : scrapy_spider
"https://github.com/k713927/phone_spider/blob/master/utils/PddAppRiskUtil.py"
import hashlib
import json
import random
import time

import parsel
import requests
from loguru import logger

from apps.pdd.pdd.utils.js import MSG_MAP


class PDDAppRiskUtil:

    @staticmethod
    def pdd_get_xPDD_QUERIES(device_info):
        # return "width=" + device_info['width'] + "&height=" + device_info['height'] + "&net=4&brand=" + device_info[
        # 	'brand'] + "&model=" + device_info['model'] + "&osv=" + device_info['release'] + "&appv=4.79.0&pl=2"
        # "width=1240&height=2662&net=1&brand=OnePlus&model=PHP110&osv=14&appv=7.27.0&pl=2"
        return (
            "width="
            + device_info["width"]
            + "&height="
            + device_info["height"]
            + "&net=1&brand="
            + device_info["brand"]
            + "&model="
            + device_info["model"]
            + "&osv="
            + device_info["release"]
            + "&appv=7.27.0&pl=2"
        )

    @staticmethod
    def pdd_get_user_agent(device_info):
        return (
            "android Mozilla/5.0 (Linux; Android "
            + device_info["release"]
            + "; "
            + device_info["model"]
            + " Build/"
            + device_info["buildId"]
            + "; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36  phh_android_version/7.27.0 phh_android_build/db72786ed8b2dc5fedcc87ebb349b961cbf46046 phh_android_channel/gw pversion/0"
        )

    @staticmethod
    def x_b3():
        now = int(time.time())
        salt = str(random.randint(100000, 999999))
        token = salt + str(now) + salt
        return hashlib.md5(token.encode(encoding="UTF-8")).hexdigest()

    def get_etag(self, device_info, etag_data, proxy=""):
        """
        {
          "app_info": {
            "cur_version": "1.9.0",
            "min_version": "1.0.0",
            "api_domain": "http://api.yangkeduo.com",
            "app_domain": "http://app.yangkeduo.com",
            "chat_service": "ws://ws.yangkeduo.com/"
          },
          "pdd_id": "oyfPqW5K",
          "server_time": 1727228543,
          "ext_data": {
            "pcd": "0",
            "type_5_config": "1",
            "access_type": "1",
            "wtp": "1",
            "phantom_all": "1",
            "javah": "0",
            "phantom_span": "20,300,1000",
            "extra_access": "0",
            "rc_exp": "rFqi",
            "phantom_config": "3",
            "ds": "{\"on\":\"1\",\"bl\":[],\"co\":\"\"}"
          }
        }
        :param device_info:
        :param etag_data:
        :param proxy:
        :return:
        """
        proxies = {"http": proxy, "https": proxy}
        data = etag_data
        headers = {
            "Referer": "Android",
            "X-PDD-QUERIES": self.pdd_get_xPDD_QUERIES(device_info),
            "ETag": "",
            "p-appname": "pinduoduo",
            "x-b3-ptracer": self.x_b3(),
            "User-Agent": self.pdd_get_user_agent(device_info),
            "PDD-CONFIG": "00102",
            "Content-Type": "application/json",
            # "Content-Length": 2881,
            "Host": "meta.yangkeduo.com",
            # "Connection": "Keep-Alive",
            # "Accept-Encoding": "gzip",
            # "Cookie": "api_uid=CiSW114JyTQrwgBSBZviAg==",
        }
        headers = {
            "User-Agent": self.pdd_get_user_agent(device_info),
            "Accept-Encoding": "gzip",
            # "accesstoken": "SXEXCNU2QD5EU2IL2EV5WBZSOITSGWDZ2R2U6NOZG7DEZQBTQJQA1201a4e",
            # "anti-token": "2agk5u+IngsL7fKMFC7EwDMWJr/CIcOL+CzpCBK+RR4KuuGoCbFpUSKVW0xGHrQ+T3qBnGFppfWDUhjxIfdBjkIDg==",
            "content-type": "application/json;charset=UTF-8",
            "etag": "",
            # "lat": "TK4ZI6UKBCKQ2KTQU7GLRIKIPDCM7TICC6HIWDTCNJFZE4DISKMQ1201a4e",
            "multi-set": "0,1,",
            "p-appname": "pinduoduo",
            "p-mediainfo": "player=2.0.4&rtc=1.0.0",
            "p-proc": "main",
            "p-proc-time": "3498",
            "pdd-config": "V4:001.072700",
            "referer": "Android",
            "x-b3-ptracer": "hctruecfd752e7cd684eb788ed09303c",
            "x-p-t": "t=0&x-p1-t=0",
            # "x-p1": "MDQwMTAxc3Jqamg1YVgtVFltQS0yeXkxLTEzMTAtNUNZR051T2xNY0dNbRgaCUIa8ub3wsl9zPXXXaD9fhXcBJUi+Pw8J5XICfiu2M9G0YpFzUNy44t1LEb1cq+FyOTp4R1mCPOY4cYhF8s/wTqa2BaqovVH3fRi",
            "x-pdd-info": "bold_free%3Dfalse%26bold_product%3D%26front%3D1%26tz%3DAsia%2FShanghai",
            "x-pdd-queries": self.pdd_get_xPDD_QUERIES(device_info),
            # "x-yak-llt": "1727078201297"
        }
        # cookies = {
        #     "acid": "ee5fb540f54b3e96d53ba75fde57e308",
        #     "api_uid": "CiCkMGbs59N35wB7aatYAg=="
        # }
        data = {
            "key": "rsZk68UDuPrcN0DjtqvWzF91X4pN1GuW29N2t9P7S8kRURLGiqUrt2HtNcWPUZFRYC7WBwc5oFMj3D8u5x+KWalyzPTRQr7I1KNPdvB1WlHc+p0BRy9lQvbi3mdLdNXmucjrHFRrdL2UmTN8in/iYgJm0vraYL+wNzXKP2iw6q0=",
            "data": "2YAjBQUcRko8Brata4CNluVoX2RBpDMXe2NM3+cw+6DzC+Sy9ScKYE61rztmcpAfCFkhvWHXIZisDpwXjy0KL4X6diCxGVz/Cu+Wua7LT1aACjaNvaBIlWOJBzmsmHGye4Wb8Gi503q4tNqddQT2Bz+nIQUXLOafLQdRewAHlrKa/Qk0YaTEoTdoP1pb7NTMR+t9i8Mu6jx99oP1xM6gVe5RhQiKItWCUYyCD4kuaekEVrrUaYqWElb60OGuksrKNFw6xHx5fNzf72rl4gmCHwVImyscXq4dd7Rqc6fQoDXOyhCd0FA6iP6BZPvTkCDGLL0VJoPpnBCv27qJCcCditcAUDqnxDQKlnUxb6lEZ2WwlZDtrYCg1fzDlglxJOZW7X9dBSx7W+6B9az+Ha9gJjth668SEOegC1yoS6NFluhobdZmb99x9xp8+SK9l0ytKQXUHxlt0kz3mK6iwOP3BN1hOih1nj6+Z+9aehvqRYK0driHQ24kbl+V+aRXL9oGcmOy/YOX7RSzpxJardZBZe/GEogcTK1fNS07Sr9z2QjV043qXpE464JRSXOdeJY0uhmfnYk1qxGMDBdG9DNn0zEK/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dgImWrMPJUAdp/Uo3YKJOgB/11tz1eulbGKMr9wf4IdzDoV/DTgfoLZF+SuWlNkzsu0ynMBx5vzCJO+1QdGldgMsRG09BZmWCt4Zqu7jlDwwF7k8e6jB5Dkts5sOw4N1jyEsu",
            "platform": "android",
            "name": "pdd",
            "collect_begin_time": 58135442,
            "collect_end_time": 58136264,
        }
        res = requests.post(
            "https://api.pinduoduo.com/project/meta_info?pdduid",
            data=json.dumps(data),
            headers=headers,
            proxies=proxies,
        ).json()
        return res["pdd_id"]


class AppCrawler:
    session = requests.Session()

    def __init__(
        self,
        cookie=None,
        etag="riCQcrlF",
        app_version="7.68.0",
        phone_name="OnePlus",
        phone_model="PHP110",
        phone_width=1240,
        phone_height=2662,
        os_version="14",
    ):
        if cookie is None:
            cookie = {}
        self.base_url = "https://api.pinduoduo.com"
        self.session.headers = {
            "p-mediainfo": "player=2.0.4&rtc=3.0.0",
            "referer": "Android",
            "x-pdd-queries": f"width={phone_width}&height={phone_height}&net=1&brand={phone_name}&model={phone_model}&osv={os_version}&appv={app_version}&pl=2",
            "p-appname": "pinduoduo",
            "pdd-config": f"V4:001.0{app_version.split('.')[0]}{app_version.split('.')[1].zfill(2)}00",
            "x-pdd-info": "bold_free%3Dfalse%26bold_product%3D%26front%3D1%26tz%3DAsia%2FShanghai",
            "etag": etag,
            "p-proc": "main",
            "x-b3-ptrace": "main",
            "user-agent": f"android Mozilla/5.0 (Linux; Android {os_version}; {phone_model} Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36  phh_android_version/{app_version} phh_android_build/db72786ed8b2dc5fedcc87ebb349b961cbf46046 phh_android_channel/gw pversion/0",
        }
        # "cookie": 'acid=cd0c28122a2a98afaed2fef53f368a5e; api_uid=CiCkMGbs59N35wB7aatYAg==',
        self.session.cookies.update(cookie)
        cookies = self.session.cookies.get_dict()
        self.pdd_user_id = cookies["pdd_user_id"]

    @staticmethod
    def _resolve_raw_data(html):
        response = parsel.Selector(html)
        raw_data = response.re_first(r"window\.rawData\s*=\s*(\{.*\});")
        if not raw_data:
            logger.error("未获取到数据")
            return False
        raw_data = json.loads(raw_data)
        return raw_data

    def get_mall_info(self, mall_id="409099714"):
        url = f"https://m.pinduoduo.net/mall_subject.html?_t_rpn=comm_mall_guarantees&source=2&mall_id={mall_id}&msn=&page_id="
        logger.debug(f"获取店铺url：{url}")
        resp = self.session.get(url).text
        raw_data = self._resolve_raw_data(resp)
        if raw_data is False:
            logger.error(f"店铺【{mall_id}】没有信息 可能账号被封禁")
            return
        mall_basic_info = raw_data["store"]["mallDetailInfo"]["mallBasicInfo"]
        mall_name = mall_basic_info.get("mallName")
        if not mall_name:
            logger.error(f"店铺【{mall_id}】没有信息 可能账号被封禁")
            return
        logger.info(f"店铺详情：【{mall_id}】【{mall_name}】")
        logger.info(f"获取到店铺信息为：{mall_basic_info}")
        logger.info(f"获取到店铺原始信息为：{raw_data['store']}")

    def get_mall_goods_info(self, mall_id, pdd_uid, page_no=1):
        headers = {
            "User-Agent": "android Mozilla/5.0 (Linux; Android 14; PHP110 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36  phh_android_version/7.8.0 phh_android_build/bf793aa528affe1b01408904fabc55be5b816173_pdd_patch phh_android_channel/yyb pversion/5488",
            "Accept-Encoding": "gzip",
            "accesstoken": "XGBHFRC422WGQEUHOSBJFVSVONS7GPAVQ3MPDFCPVOQWXFUONOPA1206869",
            "anti-token": "2af4wbyFO5pw3/mISxNLZYvoXXrVN+gA6lDyHvDDIks4gBPlvaE6Zrkp8OmuALY0OyzZtzyUG36MB2h8CVkaVmZnKjZcY1804KDoJQyveFzVZxbWFAtUNuFC6SM+jxUp9iRBGi99aPUdZ8sD9F4+pTM2Ysg/pe1yzNLKhamChvKBddkVXiuJJlZpv6+bhcWlBxNhMTriXapIdjbkLgfaypXJ8Cg1XurFQtmJuugMLGa4Bw4MjcizbakQ26L6Nm2Uq38lAZUdPmUVyIf3Df8uBTBbi89xodqScuBJxrYkxIaSmWd/ri7575N/4p7rk2zs5J3yaF759EEMDGRmW6WmzXDgQbvmpMF4YFrWeO+PcbxiAhJnuicI6bK4WMaPHBUEQkz6f22hn9OJ0+Os3NWie3Rixgh41a8DxeiQgvfJx8NRLhPYNsi5R7p57UhkvcwR4Sen5rYtZhFdkERIzDhpPAvFvOC1tOncMz81fIcw3vSZ5C3dK6BP5+V8my+buUTE6dd",
            "content-type": "application/json;charset=UTF-8",
            "etag": "oyfPqW5K",
            "lat": "JJP5BY7ZHKOR35G5J57DBK3P452TZ67RI5F237DTCOHNFYZOOFJA1225596",
            "multi-set": "1,1,25",
            "p-appname": "pinduoduo",
            "p-mediainfo": "player=2.0.4&rtc=3.0.0",
            "p-proc": "main",
            "p-proc-time": "317660",
            "pdd-config": "V4:001.070800",
            "referer": "Android",
            "x-b3-ptracer": "hctrue438c5de7287442fc878dfff9df",
            "x-pdd-info": "bold_free%3Dfalse%26bold_product%3D%26front%3D1%26tz%3DAsia%2FShanghai",
            "x-pdd-queries": "width=1240&height=2662&net=1&brand=OnePlus&model=PHP110&osv=14&appv=7.8.0&pl=2",
            "x-yak-llt": "1727243120250",
        }
        cookies = {"acid": "c1a2d707f3703ac9c9b24662edf62f15", "api_uid": "Ck2oaWbzoyNn+QBYOykbAg=="}
        url = "https://api.pinduoduo.com/api/turing/mall/query_cat_goods"
        params = {
            "mall_id": "222447188",
            "page_no": "3",
            "list_id": "1feb731a14222447188",
            "msn": "4gi7vflbv7dnsf73x3jovjuyvq_axbuy",
            "goods_id": "579061435153",
            "page_size": "20",
            "sort_type": "default",
            "show_priority_type": "0",
            "category_id": "0",
            "type": "0",
            "query": "",
            "page_from": "39",
            "refer_pdd_type": "0",
            "goods_show_types": "1",
            "refer_page_sn": "10014",
            "display_flag": "activity_region",
            "query_shipping_option": "1",
            "page_id": "mall_page.html",
            "goods_list_show_type": "0",
            "engine_version": "2.0",
            "pdduid": pdd_uid,
        }
        resp = self.session.get(url, params=params, headers=headers).json()
        logger.info(f"获取到商品列表为：{resp}")
        if resp.get("error_code") == 40001:
            logger.error(MSG_MAP.get(resp.get("error_code")))

        url = f"{self.base_url}/api/turing/mall/query_cat_goods"
        params = {
            "has_played_cycle_photo": "0",
            "list_id": "a26e33e1bc220743595",
            "query": "",
            "refer_page_sn": "10014",
            "first_request": "1",
            "goods_id": "",
            "display_flag": "activity_region",
            "msn": "msi53ircjkw7tvfasoho3qkfly_axbuy",
            "page_no": page_no,
            "type": "0",
            "has_played_video": "0",
            "show_priority_type": "0",
            "query_shipping_option": "1",
            "sort_type": "default",
            "page_id": "mall_page.html",
            "page_from": "39",
            "refer_pdd_type": "0",
            "category_id": "0",
            "mall_id": mall_id,
            "goods_list_show_type": "0",
            "engine_version": "2.0",
            "page_size": "20",
            "pdduid": self.pdd_user_id,
        }
        headers = {
            **self.session.headers,
            "anti-token": "2afsxwAAFBSFZ00RizSEglOzoL9T4gZotOspUOnsqzynltaS31Z4+bjZTXWZvxBnR7a7Of0JYqj7tEFV51MKq4J5AbmD2Nqfx0QUkaYPLE5vx9hkzxa/UkNd7Ogu3/+/03wtXl7+yCTJEhvlWK44tZipeNFWWH2AObVnZnkpqsnHaDy3IgSM/KXzT8KERlMuV8jdvq1dzALM9vJJ30XgQXgvY0ezZIvCDO1/CyqYv0f/EDYV7y+6TngrqqHQHU17+D+Kk5/9dKYLtelApMqqDYEk0Cr8tYbtlvfkpJmEhI+eEEcxazgeWgxd2nZxNWoY1rMKdDX909xsknsezk+lie+eZWkGBpkIcNo2kDA/V5YQbsX62O+oFDB+EdQJjohf+UE07OqesZaTwmqqXEahor6zHTz/ygFf/JAnEc6bCk32bfojuChOSyf4SjQ2quZkngsSbpxqBcj8fDZtGYW+TYAptQlyXcXrBU8VFoGHBFj/4f1swN2uD5gWetLyo7kG04o",
            "accesstoken": "5PX5XNJDLM2XKLB4X2AFCMBKRVZQR2HDISUSTP3JWL63LO2S37LQ120ae96",
            "p-proc-time": f"{random.randint(37501, 67501)}",  # 时间差
            "x-yak-llt": f"{int(time.time() * 1000)}",
        }
        resp = self.session.get(url, params=params, headers=headers).json()
        logger.info(f"获取到商品列表为：{resp}")
        if resp.get("error_code") == 40001:
            logger.error(MSG_MAP.get(resp.get("error_code")))

    def get_goods_info(self, goods_id):
        headers = {
            "User-Agent": "android Mozilla/5.0 (Linux; Android 14; PHP110 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36  phh_android_version/7.8.0 phh_android_build/bf793aa528affe1b01408904fabc55be5b816173_pdd_patch phh_android_channel/yyb pversion/5488",
            "Accept-Encoding": "gzip",
            "accesstoken": "XGBHFRC422WGQEUHOSBJFVSVONS7GPAVQ3MPDFCPVOQWXFUONOPA1206869",
            "anti-token": "2agIhsqeBg5/XtlgTmv6zepS/tDDEj5vdDIkqcxDq08xoMwwIfG9VdXu628o1zOX8vBddbGNuBd4hXBEMV91XxVpw==",
            "content-type": "application/json;charset=UTF-8",
            "etag": "oyfPqW5K",
            "lat": "JJP5BY7ZHKOR35G5J57DBK3P452TZ67RI5F237DTCOHNFYZOOFJA1225596",
            "multi-set": "1,1,100000824",
            "p-appname": "pinduoduo",
            "p-mediainfo": "player=2.0.4&rtc=3.0.0",
            "p-proc": "main",
            "p-proc-time": "4522523",
            "pdd-config": "V4:001.070800",
            "referer": "Android",
            "x-b3-ptracer": "hctrue440ffb39668e44eda44b739bed",
            "x-pdd-info": "bold_free%3Dfalse%26bold_product%3D%26front%3D1%26tz%3DAsia%2FShanghai",
            "x-pdd-queries": "width=1240&height=2662&net=1&brand=OnePlus&model=PHP110&osv=14&appv=7.8.0&pl=2",
            "x-yak-llt": "1727243120250",
        }
        cookies = {"acid": "c1a2d707f3703ac9c9b24662edf62f15", "api_uid": "Ck2oaWbzoyNn+QBYOykbAg=="}
        url = "https://api.pinduoduo.com/api/oak/integration/render"
        params = {"pdduid": "9399048945768"}
        data = {
            "address_list": [],
            "page_sn": "10014",
            "page_id": "10014_1727248222531_1101169162",
            "goods_id": "493269769425",
            "phone_model": "PHP110",
            "page_from": "39",
            "page_version": "7",
            "client_time": "1727248222531",
            "refer_page_sn": "10039",
            "refer_page_el_sn": "99755",
            "pic_w": 0,
            "pic_h": 0,
            "has_pic_url": 1,
            "_oc_trace_mark": "199",
            "extend_map": {"_oc_trace_mark": "199"},
            "_oak_rcto": "YWKF_Vd2-__RPBuzcVgOUZAOmDGuVvrfM8U",
            "client_lab": {"mall_h5_url_preload_enable": "1"},
            "cached_templates": [
                "ee7a17f983c1b745e13e3b29982aa0fa",
                "f030ffc32e219d7e5c19aed6079e7eb2",
                "4cb686aa9d52ed9214853abb540f1927",
                "c1c2c204d1a76d4de892bd6e139a0380",
                "d314c845f72b06470d4ff2d10ad1a5d6",
                "07c50532dcf7ab5b4d6fc28a73704913",
                "11a6c4cbd20b7cf820104faf7e5952f4",
                "2fa1af6f6ff625403fa10ca845d3715a",
                "ee7a17f983c1b745e13e3b29982aa0fa",
                "f030ffc32e219d7e5c19aed6079e7eb2",
                "4cb686aa9d52ed9214853abb540f1927",
                "c1c2c204d1a76d4de892bd6e139a0380",
                "d314c845f72b06470d4ff2d10ad1a5d6",
                "2fa1af6f6ff625403fa10ca845d3715a",
                "07c50532dcf7ab5b4d6fc28a73704913",
            ],
            "impr_tips": [],
        }
        data = json.dumps(data, separators=(",", ":"))
        response = requests.post(url, headers=headers, cookies=cookies, params=params, data=data)

        print(response.text)
        print(response)


if __name__ == "__main__":
    ck = {
        # "api_uid": "Ck5oxWYcgAZgjQBYU9WdAg==",
        # "_nano_fp": "XpmaXqgYXqCxn5TJn9_e2MsNWzUS3ffo16ozNr7~",
        # "PDDAccessToken": "26DSZ3PG65OHAMXNLQIGRLXUKBMFE6SVSEVJQT5CX7ELVC6CCA4A121c274",
        # "pdd_user_id": "1576526274",
        # "pdd_user_uin": "YD7VU6OJE2DG3NSYML6ZPXB5DE_GEXDA",
        "api_uid": "CiZuSGauOoAfEQBTE026Ag==",
        "_nano_fp": None,
        "PDDAccessToken": "PUTY6PWDEWZD4MC2A2CR647BKMSHTV3P57C7CZLZ5FG33AX7KGIQ121c274",
        "pdd_user_id": "1576526274",
        "pdd_user_uin": "YD7VU6OJE2DG3NSYML6ZPXB5DE_GEXDA",
        "pdd_vds": None,
        # 'api_uid': 'CiHu0WauOy4+2QCGE3FzAg==', '_nano_fp': None, 'PDDAccessToken': 'XJLEILJVS3AGY5ISD3BWF4WI2DIV37L2F26RU74WODFNGFQ24IUA123d466', 'pdd_user_id': '7816067872724',
        # 'pdd_user_uin': 'GZMP25DYC5D4HUTUDRQAVMMOIQ_GEXDA', 'pdd_vds': None
    }
    test = AppCrawler(ck)
    # test.get_mall_info(mall_id="409099714")
    # test.get_mall_info(mall_id="102801257")
    # test.get_mall_goods_info(mall_id="102801257", page_no=1)
    # test.get_mall_goods_info(mall_id="102801257", page_no=2)
    # test.get_mall_goods_info(mall_id="102801257", page_no=3)
    # test.get_mall_goods_info(mall_id="1052959", page_no=1)
    # test.get_mall_goods_info(mall_id="1052959", page_no=2)
    # test.get_mall_info(mall_id="1052959")
    # test.get_mall_info(mall_id="109548654")
    test.get_mall_info(mall_id="109744208")
    # test.get_goods_info(goods_id='603056777621')
    # test.get_mall_goods_info(mall_id='409099714')
